<template>
  <div id="operate">  
        <div  style="display:flex;margin-bottom:10px;align-items: center;">
            <img class="top_img" src="@/assets/images/a8.png" style="width:35px;height:35px;margin-right:10px;"/>
            <div style="line-height: 40px;font-weight:bold:">运营中心</div>
     </div> 

    <el-form ref="form"  label-width="80px"> 

      <div style="display:flex;align-items: center;">
          <div style="width:50px;text-align-last: justify;margin-top:-12px;font-size: 14px;color: #606266;margin-right:0px;">查询项</div>
              <el-form-item label="手机号码" >
                <el-input v-model="form.phone" placeholder="姓名/手机号" style="width:140px;"></el-input>
              </el-form-item>    
          <el-row  style="display:flex;">            
              <el-row  style="display:flex;"> 
                  <el-form-item label="好友区间" label-width="80px" >
                        <div style="display: flex;">
                            <el-input style="width:80px;" v-model.number="form.friend_min" placeholder="" disabled></el-input>
                            <div style="width:20px;height:40px;line-height:40px;text-align: center;"> - </div>
                            <el-input  style="width:80px;" v-model.number="form.friend_max" placeholder="" disabled></el-input>
                        </div>
                  </el-form-item>   
                  <el-form-item label="团队区间" label-width="80px" >
                        <div style="display: flex;">
                            <el-input style="width:80px;" v-model.number="form.team_min" placeholder="" disabled></el-input>
                            <div style="width:20px;height:40px;line-height:40px;text-align: center;"> - </div>
                            <el-input  style="width:80px;" v-model.number="form.team_max" placeholder="" disabled></el-input>
                        </div>
                  </el-form-item>  
                  <el-form-item label="贡献查询" label-width="80px" >
                        <div style="display: flex;">
                            <el-input style="width:80px;" v-model.number="form.gx_min" placeholder="" disabled></el-input>
                            <div style="width:20px;height:40px;line-height:40px;text-align: center;"> - </div>
                            <el-input  style="width:80px;" v-model.number="form.gx_max" placeholder="" disabled></el-input>
                        </div>
                  </el-form-item>       
                </el-row>
         </el-row>
        <div class="buttoon_box">
            <div class="buttoon_box_item"  style="margin-left:10px;background:#FFC600;color:white;" @click="search_but1()">确 定</div>
            <div class="buttoon_box_item" style="margin-left:10px;border:1px solid #D9D9D9;" @click="sx_but()">清 空</div>    
        </div>

    </div>

     <el-row> 
             <el-col :span="24" style="text-align: right;">   
                <el-button type="primary" class="custom_color_button1" style="margin-bottom:10px;" @click="add_but()">
                  <img class="custom_color_button1_img" src="@/assets/images/but_bg2.png" />添加
                </el-button>         
             </el-col>  
    </el-row>
   </el-form>
   <!-- 渲染数据list -->
   <operate-list :datalist="datalist" @up_list_fun="list_fun"> </operate-list>

      
   <div style="margin-top:20px;text-align: center;">
      <el-pagination
        background
        @current-change="handleCurrentChange"
        :page-size="10"  
        layout="prev, pager, next, jumper"
        :total="count">
      </el-pagination>
    </div>

       <!-- 添加 -->
        <el-dialog title="添加" :visible.sync="mtk"  width="400px">
            <div style="width:100%;"> 

            <el-form ref="form"   label-width="70px" style="width:100%;">
                 <el-form-item label="名称" label-width="70px" >
                    <el-input v-model="mtk_form.name" placeholder="名称"></el-input>
                </el-form-item> 
                 <el-form-item label="手机号" label-width="70px" >
                    <el-input v-model="mtk_form.telphone" placeholder="手机号"></el-input>
                </el-form-item> 
                <el-form-item label="头像" label-width="70px" >
                      <el-upload 
                            action="uploadUrl"  
                            :show-file-list="false"   
                            :before-upload="beforeupload"
                            :http-request="ImgUploadSectionFile">
                            <div class="avatar-uploader">
                                <img v-if="mtk_form.head_img"  :src="mtk_form.head_img" class="avatar">
                                <i v-else class="el-icon-plus avatar-uploader-icon"></i>
                            </div>
                      </el-upload>
                </el-form-item>                               
            </el-form>

                <div style="text-align: center;width:50%;margin:auto;margin-top:30px;">
                    <el-button type="primary" class="custom_color_button" style="width:100%;" @click="mtk_but_qr">确认</el-button>
                </div>

            </div> 
        </el-dialog>

    

      
  </div>
</template>

<script>
import OperateList from '@/view/Member/OperateList'
export default {
  name: 'operate',
  data () {
    return {
        datalist:[],
        page:1,
        count:0,
        form:{
          phone:'',
          friend_min:'',
          friend_max:'',
          team_min:'',
          team_max:'',
          gx_min:'',
          gx_max:'',
        },
        mtk:false,
        mtk_form:{
          name:'',
          head_img:'',
          upfile:'',
          telphone:''
        }
    }
  },
 components:{
    OperateList
  },
  created(){
     this.list_fun()
  },
  mounted (){
    
  },
  methods: {
      list_fun(){
          this.post("/operate_center/listOfData", {
              page:this.page,
              account:this.form.phone,
	        }).then(res => {
            this.count = res.result.count
            this.datalist = res.result.list
            console.log(res)
         })
      },
      add_but(){
        this.mtk_form.name = ''
        this.mtk_form.upfile = ''
        this.mtk_form.head_img = ''
        this.mtk_form.telphone = ''
        this.mtk = true
      },
      mtk_but_qr(){
          this.post("/operate_center/create", {
              name:this.mtk_form.name,
              icon:this.mtk_form.upfile,
              telphone:this.mtk_form.telphone
	         }).then(res => {
             if(res.error_code == 0){
                     this.page = 1
                    this.list_fun()
                    this.mtk = false
                    console.log(res)
                     this.open1(res.result,'success')  //提示框
                }else {
                    this.open1(res.message,'warning')
                }

          })
      },
      search_but(){
       
      },
      ImgUploadSectionFile(param){//图片上传    
      },
      beforeupload(file){
        if(this.upimglx(file) == false){  //判断是否为fales
              this.upimglxtitle()  //执行弹出错误             
              return false
            }  
            var windowURL = window.URL || window.webkitURL;               
            this.mtk_form.head_img=windowURL.createObjectURL(file);                
            
             this.upimgpost("/image/uploadMultiple",file).then(res => {
               console.log(res.result.url )
               this.mtk_form.upfile = res.result.url    
            })

            return false;

     },
     search_but1(){
        this.page = 1
          this.list_fun()
     },
     sx_but(){
        this.form={
          phone:'',
        },
        this.page = 1
        this.list_fun()
     },
     handleSizeChange(val) {
        console.log(`每页 ${val} 条`);
      },
      handleCurrentChange(val) {
        this.page = val
        this.list_fun()
        console.log(`当前页: ${val}`);
      }
  }
}
</script>


<style scoped>
.avatar-uploader  {
    border: 1px dashed #d9d9d9;
    border-radius: 6px;
    cursor: pointer;
    position: relative;
    overflow: hidden;
  }
  .avatar-uploader-icon {
    font-size: 28px;
    color: #8c939d;
    width: 150px;
    height: 150px;
    line-height: 150px;
    text-align: center;
  }
  .avatar {
    width: 150px;
    height: 150px;
    display: block;
  }
</style>
